/*
	 * Click event for create button
	 * Creates new value of data being displayed in Modal form
	 * Refreshes data table on successful creation
	 * 
	 * Calls 
	 * refreshMyTable()
	 * 
	 * converter()
	 * <SerializedArray> - Serialized Array of Form Data
	 */
	    $("#submit").click(function(){
    	if($('#getDetailsForm').valid()) {
		formData = ($('#getDetailsForm').serializeArray());
 
		$.ajax({
		    url : 'http://localhost:8080/easyskool/rest/userauthservice/setDetails',
			type : 'POST',
			async: false,
			data : '{"user":"sumit","updateClause":'+ converter(formData)+','+'"whereClause":'+getCode()+ '}',
			dataType : 'json',
			contentType : "application/json; charset=utf-8",
			success : function(data,testStatus,jqXHR) {
				var json = jQuery.parseJSON(jqXHR.responseText);
					if(json.responseMessage == "success"){
						alert("Record Successfully Stored..");
						  window.location.assign("http://localhost:8080/easyskool/Login/login.jsp");
						  } else	{
						alert("Error Saving Record");
					}
			}
	    });
    	}
	});
    
	    function getCode()
	    {
	    	var id=document.getElementById("id").value;
	    	var type=document.getElementById("type").value;	
	    	alert(type);
	    	var str='{"code":"'+id+'","type":"'+type+'"}';
	    	return str;
	    	
	    }